clear all
use "datasets/MRA_waste_sites"

*------------------------------------------------------------------------------*
* TABLE A9 : Subsample analyses
*------------------------------------------------------------------------------*

* Due to manual WLS-RE, each regression composes of the same repeating steps that involve generating 'new' variables starting from the 'metareg' results. This results in lengthy codelines but is considered necessary for manual WLS-RE. For the same reason, the resulting tables using 'outreg2' have to be manually altered to give the same format as the published tables. The coefficients are, of course, identical.

*------------------------------------------------------------------------------*
* Replacing dist_greater_mean with miles_km
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear miles_km sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_1 = elas_var + tau2
gen elas_SE_1 = sqrt(elas_var_1)
gen precision_sq_1 = 1/elas_var_1
gen precision_1 = sqrt(precision_sq_1)

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear miles_km sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'1 = `var'/elas_SE_1
}

reg elas1 precision_1 elas_var1 publish1 year_publish_c1 site_m1 NPL_n1 NPL_y1 NPL_u1 active_n1 active_u1 job_n1 job_u1 non_haz1 nuclear1 air1 water1 element_u1 North_America1 Asia1 Other_continent1 cleanup01 cleanup21 cleanup31 cleanup_unclear1 miles_km1 sample_c1 sale_ind1 num_expl_c1 oth_disamen1 oth_amen1 access1 industry1 demoecon1 time_control1 direction1 interaction1 log_log1 OLS_spatial1, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", replace dec(3) ctitle(Miles_km)

*------------------------------------------------------------------------------*
* Replacing continent dummies with HDI-index
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u HDI_c cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_2 = elas_var + tau2
gen elas_SE_2 = sqrt(elas_var_2)
gen precision_sq_2 = 1/elas_var_2
gen precision_2 = sqrt(precision_sq_2)

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u HDI_c cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'2 = `var'/elas_SE_2
}

reg elas2 precision_2 elas_var2 publish2 year_publish_c2 site_m2 NPL_n2 NPL_y2 NPL_u2 active_n2 active_u2 job_n2 job_u2 non_haz2 nuclear2 air2 water2 element_u2 HDI_c2 cleanup02 cleanup22 cleanup32 cleanup_unclear2 dist_greater_mean2 sample_c2 sale_ind2 num_expl_c2 oth_disamen2 oth_amen2 access2 industry2 demoecon2 time_control2 direction2 interaction2 log_log2 OLS_spatial2, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(HDI)

*------------------------------------------------------------------------------*
* Subset of hazardous waste sites
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u  air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial if haz==1, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_3= elas_var + tau2
gen elas_SE_3 = sqrt(elas_var_3)
gen precision_3= 1/(elas_SE_3)
gen precision_sq_3= 1/elas_var_3

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'3 = `var'/elas_SE_3
}

reg elas3 precision_3 elas_var3 publish3 year_publish_c3 site_m3 NPL_n3 NPL_y3 NPL_u3 active_n3 active_u3 job_n3 job_u3 air3 water3 element_u3 North_America3 Asia3 Other_continent3 cleanup03 cleanup23 cleanup33 cleanup_unclear3 dist_greater_mean3 sample_c3 sale_ind3 num_expl_c3 oth_disamen3 oth_amen3 access3 industry3 demoecon3 time_control3 direction3 interaction3 log_log3 OLS_spatial3 if haz==1, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(Hazardous waste site)

*------------------------------------------------------------------------------*
* Replacing num_var with num_sig_var
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_sig_var_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_4 = elas_var + tau2
gen elas_SE_4 = sqrt(elas_var_4)
gen precision_sq_4 = 1/elas_var_4
gen precision_4 = sqrt(precision_sq_4)

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean miles_km sample_c sale_ind num_sig_var_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'4 = `var'/elas_SE_4
}

reg elas4 precision_4 elas_var4 publish4 year_publish_c4 site_m4 NPL_n4 NPL_y4 NPL_u4 active_n4 active_u4 job_n4 job_u4 non_haz4 nuclear4 air4 water4 element_u4 North_America4 Asia4 Other_continent4 cleanup04 cleanup24 cleanup34  cleanup_unclear4 dist_greater_mean4 sample_c4 sale_ind4 num_sig_var_c4 oth_disamen4 oth_amen4 access4 industry4 demoecon4 time_control4 direction4 interaction4 log_log4 OLS_spatial4, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(Significant variables)

*------------------------------------------------------------------------------*
* Omitting observations that originate from interactions
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial if interaction==0, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_5= elas_var + tau2
gen elas_SE_5 = sqrt(elas_var_5)
gen precision_5= 1/(elas_SE_5)
gen precision_sq_5= 1/elas_var_5

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u North_America Asia Other_continent cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'5 = `var'/elas_SE_5
}

quietly reg elas5 precision_5 elas_var5 publish5 year_publish_c5 site_m5 NPL_n5 NPL_y5 NPL_u5 active_n5 active_u5 job_n5 job_u5 non_haz5 nuclear5 air5 water5 element_u5 North_America5 Asia5 Other_continent5 cleanup05 cleanup25 cleanup35 cleanup_unclear5 dist_greater_mean5 sample_c5 sale_ind5 num_expl_c5 oth_disamen5 oth_amen5 access5 industry5 demoecon5 time_control5 direction5 interaction5 log_log5 OLS_spatial5 if interaction==0, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(No interaction)

*------------------------------------------------------------------------------*
* Replacing continent dummies with GDP
*------------------------------------------------------------------------------*
quietly metareg elas elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u GDP_pc_national_2010_USD_c cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_6 = elas_var + tau2
gen elas_SE_6 = sqrt(elas_var_6)
gen precision_sq_6 = 1/elas_var_6
gen precision_6 = sqrt(precision_sq_6)

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u GDP_pc_national_2010_USD_c cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean miles_km sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'6 = `var'/elas_SE_6
}

reg elas6 precision_6 elas_var6 publish6 year_publish_c6 site_m6 NPL_n6 NPL_y6 NPL_u6 active_n6 active_u6 job_n6 job_u6 non_haz6 nuclear6 air6 water6 element_u6 GDP_pc_national_2010_USD_c6 cleanup06 cleanup26 cleanup36 cleanup_unclear6 dist_greater_mean6 sample_c6 sale_ind6 num_expl_c6 oth_disamen6 oth_amen6 access6 industry6 demoecon6 time_control6 direction6 interaction6 log_log6 OLS_spatial6, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(GDP)

*------------------------------------------------------------------------------*
* North America only 
*------------------------------------------------------------------------------*
quietly metareg elas elas_SE publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial if North_America==1, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_7= elas_var + tau2
gen elas_SE_7 = sqrt(elas_var_7)
gen precision_7= 1/(elas_SE_7)
gen precision_sq_7= 1/elas_var_7

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial{
gen `var'7 = `var'/elas_SE_7
}

reg elas7 precision_7 elas_SE7 publish7 year_publish_c7 site_m7 NPL_n7 NPL_y7 NPL_u7 active_n7 active_u7 job_n7 job_u7 non_haz7 nuclear7 air7 water7 element_u7 cleanup07 cleanup27 cleanup37 cleanup_unclear7 dist_greater_mean7 sample_c7 sale_ind7 num_expl_c7 oth_disamen7 oth_amen7 access7 industry7 demoecon7 time_control7 direction7 interaction7 log_log7 OLS_spatial7 if North_America==1, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(North America)

*------------------------------------------------------------------------------*
* North America including state level dummies
*------------------------------------------------------------------------------*

quietly tabulate subnationalstatedistrict, gen(state)

gen other_state=1 if state1==1
replace other_state=1 if state2==1
replace other_state=1 if state3==1
replace other_state=1 if state6==1
replace other_state=1 if state7==1
replace other_state=1 if state8==1
replace other_state=1 if state13==1
replace other_state=1 if state15==1
replace other_state=1 if state17==1
replace other_state=1 if state18==1
replace other_state=1 if state19==1
replace other_state=1 if state23==1
recode other_state(.=0)

quietly metareg elas elas_SE publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial other_state state5 state9 state10 state11 state12 state14 state16 state20 state21 state22 state24 state25 state26 if North_America==1, wsse(elas_SE) tau2test

scalar tau2 = e(tau2)
display tau2
gen elas_var_8 = elas_var + tau2
gen elas_SE_8 = sqrt(elas_var_8)
gen precision_sq_8 = 1/elas_var_8
gen precision_8 = sqrt(precision_sq_8)

foreach var in elas elas_SE elas_var publish year_publish_c site_m NPL_n NPL_y NPL_u active_n active_u job_n job_u non_haz nuclear air water element_u GDP_pc_national_2010_USD_c cleanup0 cleanup2 cleanup3 cleanup_unclear dist_greater_mean miles_km sample_c sale_ind num_expl_c oth_disamen oth_amen access industry demoecon time_control direction interaction log_log OLS_spatial other_state state5 state9 state10 state11 state12 state14 state16 state20 state21 state22 state24 state25 state26{
gen `var'8 = `var'/elas_SE_8
}

reg elas8 precision_8 elas_SE8 publish8 year_publish_c8 site_m8 NPL_n8 NPL_y8 NPL_u8 active_n8 active_u8 job_n8 job_u8 non_haz8 nuclear8 air8 water8 element_u8 cleanup08 cleanup28 cleanup38 cleanup_unclear8 dist_greater_mean8 sample_c8 sale_ind8 num_expl_c8 oth_disamen8 oth_amen8 access8 industry8 demoecon8 time_control8 direction8 interaction8 log_log8 OLS_spatial8 other_state8 state58 state98 state108 state118 state128 state148 state168 state208 state218 state228 state248 state258 state268 if North_America==1, nocons cluster(ID_Study)
outreg2 using "tables/Table A9.rtf", append dec(3) ctitle(North America - FE)


clear

